package com.heima.feigns;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "leadnews-wemedia",
  configuration = HeimaFeignAutoConfiguration.class, //日志配置
fallbackFactory = WemediaFeignFallback.class) //服务降级使用
public interface WemediaFeign {


    @GetMapping("/api/v1/user/findByName/{name}")
    public ResponseResult<WmUser> getByName(@PathVariable("name") String name);

    //将泛型加上不然强转底层报错
    @PostMapping("/api/v1/user/save")
    public ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    @GetMapping("/api/v1/news/one/{id}")
    public ResponseResult<WmNews> selectById(@PathVariable Integer id);

    @PutMapping("/api/v1/news/update")
    public ResponseResult<WmNews> updateWmNews(@RequestBody WmNews wmNews);
}
